package com.leyou.item.dto;

import com.leyou.common.dto.BaseDTO;
import com.leyou.common.entity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <h3>leyou-project</h3>
 * <p></p>
 *
 * @author : hhw
 * @date : 2020-05-28 11:45
 **/
@Data
@NoArgsConstructor(staticName = "of")
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
public class SpuDetailDTO extends BaseDTO{
    private Long spuId;// 对应的SPU的id
    private String description;// 商品描述
    private String packingList;// 包装清单
    private String afterService;// 售后服务
    private String specification;// 规格参数

    public SpuDetailDTO(BaseEntity entity) {
        super(entity);
    }
    public static <T extends BaseEntity> List<SpuDetailDTO> convertEntityList(Collection<T> list) {
        if (list == null) {
            return Collections.emptyList();
        }

        return list.stream().map(SpuDetailDTO::new).collect(Collectors.toList());
    }
}
